package com.stoken.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.stoken.domain.MemberRegisterInfo;
import com.symbio.dao.hibernate.GenericDaoImpl;

@Repository("memberRegisterInfoDao")
public class MemberRegisterInfoDao extends GenericDaoImpl<MemberRegisterInfo, Long> {
	
	/**
	 * 统计一个时间段激活的会员	
	 * @return
	 */
	public List<MemberRegisterInfo> countActiveMember(){			
		String sql = "from MemberRegisterInfo where registerAvtivestate = ? and premium = ?";		
		List<MemberRegisterInfo> activeMemberRs = findList(sql,new Object[]{1,0});
		return activeMemberRs;		
	}
	
	/**
	 * 根据层级获取会员信息
	 * @param level
	 * @return
	 */
	public MemberRegisterInfo getMbRegisterByLevel(String level){
		return this.find("from MemberRegisterInfo where registerLevel = ?", new Object[]{level});	
	}
	
	/**
	 * 根据用户名查询用户注册信息
	 * @param mebaseName
	 * @return
	 */
	public MemberRegisterInfo getMbRegisterByBaseName(String mebaseName){
		 return this.find("from MemberRegisterInfo where baseUsername = ?", new Object[]{mebaseName});
		
	}
	
	/**
	 * 得到已经激活的会员列表
	 * @return
	 */
	public List<MemberRegisterInfo> getActivedMembers(){
		String sql = "from MemberRegisterInfo where registerAvtivestate = ?";		
		
		return this.findList(sql,  new Object[]{1});
	}
	
}
